package com.atguigu.lease.common.excetion;
//自定义异常处理

import com.atguigu.lease.common.result.ResultCodeEnum;
import lombok.Getter;

@Getter
public class LeaseException extends RuntimeException{

    private int code; //全局变量

    //构造器_自定义基本类型
    public LeaseException(int code, String message){
        //通过构造函数,把信息传给父类RuntimeException,利用它来处理
        super(message);
        //通过构造函数,把code传给全局变量的code,为了后期调用获取code,方便前端查看
        this.code = code;
    }

    //构造器_枚举+字符串
    public LeaseException(ResultCodeEnum messageEnum, String message){
        super(messageEnum.getMessage());
        this.code = messageEnum.getCode();
    }
    //构造器_单个枚举异常
    public LeaseException(ResultCodeEnum codeEnum) {
        //获取枚举的信息传给父类
        super(codeEnum.getMessage());

        //获取枚举的code传给全局变量code
        this.code = codeEnum.getCode();
    }
}
